package edu.sctu.practice.class02.xuqianlan.assign.assign03.Three;

import edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.*;
import edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.Circle;
import edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.CloneableCircle;

/**
 * Created by hj on 2015/11/5.
 */
public class TestCloneable {
    public static void main(String[] args) {
        edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.CloneableCircle c1 = new edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.CloneableCircle(5);
        edu.sctu.practice.class02.xuqianlan.assign.assign03.Three.CloneableCircle c2 = (CloneableCircle) c1.clone();
        System.out.println("After copying c1 to circle2.");
        if (c1 == c2)
            System.out.println("c1 and c2 reference to the same object");
        else System.out.println("c1 and c2 don't point to the same object");
        if (c1.equals(c2))
            System.out.println("c1 and c2 have the same contents");
        else
            System.out.println("c1 and c2 don't have the same contents");
        c1.setRadius(10);
        c1.getCreator().setFirstname("Michael");
        c1.getCreator().setMi("Z");

        System.out.println("\nAfter modifying c1");
        System.out.println("c1" + c1);
        System.out.println("c2" + c2);
        System.out.println();
        if (c1 instanceof Cloneable) {
            System.out.println("A CloneableCircle object is cloneable");
        } else {
            System.out.println("A CloneableCircle object is not cloneable");
        }
        Circle c = new Circle();
        if (c instanceof Cloneable) {
            System.out.println("A Circle object is cloneable");
        } else {
            System.out.println("A Circle object is not cloneable");
        }
    }
}
